package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestVo;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author oldwine
 * @date 2022/6/18
 * @Version 1.0
 */
@RestController
@RequestMapping("/hotel")
public class HotelController {
    @Autowired
    private IHotelService hotelService;

    /**
     * 搜索酒店数据
     * @param vo 用于封装前端发送的Json字符串数据对象
     * @return 返回分页查询结果
     */
    @PostMapping("/list")
    public PageResult search(@RequestBody RequestVo vo){
        return hotelService.search(vo);
    }

    /**
     * 实现对用户所有数据进行聚合
     * @param vo 请求对象
     * @return
     */
    @PostMapping("/filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestVo vo){
        return hotelService.getFilters(vo);
    }
}
